Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

deConnection.hpp

Go to the documentation of this file.
00001 ///////////////////////////////////////////////////////////////////////////////
00002 /// @file deConnection.hpp
00003 ///
00004 /// @brief 
00005 ///
00006 /// @author trajar
00007 ///
00008 /// This file is the intellectual property of Novus Delta, LLC.. Usage of the
00009 /// contents of this file is subject to the Destiny3D Member License which
00010 /// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
00011 ///
00012 /// This file is distributed "AS IS" without warranty of any kind.  Novus
00013 /// Delta, LLC. does not guarantee the fitness of the contents of this file
00014 /// for any particular purpose.
00015 ///
00016 /// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
00017 ///
00018 /// <hr>
00019 ///                                 Change History
00020 /// <hr>
00021 ///
00022 /// @date Jun 2002
00023 /// @author trajar
00024 /// @remarks Creation
00025 ///
00026 ///////////////////////////////////////////////////////////////////////////////
00027 
00028 #ifndef _DECONNECTION_HPP
00029 #define _DECONNECTION_HPP
00030 
00031 #ifndef     _DENET_HPP
00032  #include   "deNet.hpp"
00033 #endif
00034 
00035 #ifndef     _DESYNCHOBJECT_HPP
00036  #include   "deSynchObject.hpp"
00037 #endif
00038 
00039 #ifndef     _DEPACKETLIST_HPP
00040  #include   "dePacketList.hpp"
00041 #endif
00042 
00043 #include    <SET>
00044 typedef     std::set< dePacketList > aPacketLists;
00045 
00046 class dePacket;
00047 class deNetUser;
00048 class deConnectionBin;
00049 
00050 //---------------------------------------------------
00051 // deConnection
00052 //---------------------------------------------------
00053 typedef class DENET_API deConnection
00054 {
00055     friend class deConnectionProvider;
00056 
00057 public:
00058 
00059     enum fFlags
00060     {
00061         FLAG_FORCE_DISCONNECT           = 0x0002,
00062         FLAG_CONFIRM_DELIVERY           = 0x0004,
00063     };
00064 
00065     enum eType
00066     {
00067         TYPE_UNKNOWN = 0,
00068         TYPE_TCP,
00069         TYPE_UDP,
00070         TYPE_DPLAY,
00071         TYPE_BSD
00072     };
00073 
00074     deConnection(void);
00075     virtual ~deConnection(void);
00076 
00077     eNetError           ConnectTo( deNetAddress * pAddress );
00078     eNetError           AttemptReset( DWORD dwFlags = NULL );
00079     eNetError           Disconnect( DWORD dwFlags = NULL );
00080     eNetError           BindAsServer( DWORD dwFlags = NULL );
00081     eNetError           Send( WORD pNetMsgID, const void * pBuff, DWORD iSize, DWORD  dwFlags = NULL );
00082     eNetError           RecievePacket( dePacket * pPacket, DWORD dwFlags = NULL );
00083 
00084 
00085     deConnectionBin *   GetConnectionBin( void );
00086     void                SetConnectionBin( deConnectionBin * pBin );
00087     void                SetOwner( deNetUser * own );
00088     DWORD               GetDesc(void);
00089     eType               GetType(void);
00090     bool                IsReady(void);
00091     deSynchObject *     GetSynchObject(void)              { return &m_SynchObject; }    
00092     deNetUser *         GetOwner( void );
00093 
00094 #ifdef DN_SESSION_TIME_INT64
00095     s64                 GetAvgLag(void);
00096 #else
00097     float               GetAvgLag(void);
00098 #endif
00099 
00100     const deConnectionDesc *  GetConnDesc(void)           { return &m_ConnectionDesc; }
00101 
00102     static DWORD        GetMaxPacketSize(void)            { return m_MaxPacketSize; }
00103 
00104 protected:
00105 
00106     virtual eNetError   OnAttemptReset( DWORD dwFlags = NULL )                      = 0;
00107     virtual eNetError   OnBindAsServer( DWORD dwFlags = NULL )                      = 0;
00108     virtual eNetError   OnConnectTo( deNetAddress * pAddress )                      = 0;
00109     virtual eNetError   OnSend( WORD pNetMsgID, const void * pBuff, DWORD iSize, DWORD dwFlags )    = 0;    
00110     virtual eNetError   OnDisconnect( DWORD dwFlags = NULL )                        = 0;
00111 
00112 public:
00113 
00114     // used for qsort()
00115     static int CompareConnections( const void *arg1, const void *arg2 );
00116 
00117     struct deConfirmedReciept
00118     {
00119         int         ID;
00120         int         iSize;
00121         BYTE *      buffer;
00122         float       fTimeSent;
00123         float       fMaxTime;
00124     };
00125 
00126     struct dePartialReciept
00127     {
00128         int     ID;
00129         int     iSize;
00130         BYTE *  buffer;
00131         int     iIndex;
00132         int     iTotalPackets;      
00133     };  
00134 
00135 protected:
00136 
00137     eType               m_Type;
00138     deConnectionDesc    m_ConnectionDesc;
00139     
00140 private:
00141 
00142     deSynchObject       m_SynchObject;
00143     deConnectionBin *   m_ParentConnectionBin;
00144     aPacketLists        m_aPacketLists;
00145     deNetUser *         m_Owner;
00146     bool                m_bIsReady;
00147     DWORD               m_dwDesc;
00148 
00149 #ifdef DN_SESSION_TIME_INT64
00150     s64                 m_LagHistory[4];
00151     s64                 m_AvgLag;
00152 #else
00153     float               m_LagHistory[4];
00154     float               m_AvgLag;
00155 #endif
00156 
00157     static DWORD        m_MaxPacketSize;
00158 
00159 } deConnection, *pdeConnection;
00160 
00161 #endif

Generated on Mon Sep 12 19:58:25 2005 for Destiny3D by doxygen1.3-rc3